<?php
if ($this->pageCount >= 3) {
	$this->num_page_in_ranger = ($this->num_page_in_ranger)?($this->num_page_in_ranger):3;
}else {
    $this->num_page_in_ranger = $this->pageCount;
}
?>
<div class="pagination">
    <ul>
    	<?php if ($this->pageCount): ?>
    	<!-- Previous page link -->
    	<?php if (isset($this->previous)): ?>
    	    <li><a href="<?php echo $this->url(array('page' => $this->previous)); ?>">Prev</a></li>
    	<?php else: ?>
    	    <li><a href="#">Prev</a></li>
    	<?php endif; ?>

        <?php
        if (isset($this->current)) {
        	if ($this->current < ($this->num_page_in_ranger + $this->first)) {
        		for ($i = 1; $i < $this->num_page_in_ranger + 1 ; $i++) {
        			if ($this->current == $i) {
        				echo "<li class='active'><a href='". $this->url(array('page' => $i)) ."'>".$this->current."</a></li>";
        			}else {
        				echo "<li><a href='". $this->url(array('page' => $i)) ."'> $i </a></li>";
        			}
        		}
        	}else if ($this->current > ($this->last - $this->num_page_in_ranger)) {
        		for ($i = ($this->last - $this->num_page_in_ranger + 1); $i < $this->last + 1; $i++) {
        			if ($this->current == $i) {
        				echo "<li class='active'><a href='". $this->url(array('page' => $i)) ."'>".$this->current."</a></li>";
        			}else {
        				echo "<li><a href='". $this->url(array('page' => $i)) ."'> $i </a></li>";
        			}
        		}
        	}else {
        		for ($i = ($this->current - (intval($this->num_page_in_ranger/2))); $i < $this->current + (intval($this->num_page_in_ranger/2) + 1); $i++) {
        			if ($this->current == $i) {
        				echo "<li class='active'><a href='". $this->url(array('page' => $i)) ."'>".$this->current."</a></li>";
        			}else {
        				echo "<li><a href='". $this->url(array('page' => $i)) ."'> $i </a></li>";
        			}
        		}
        	}
        }
        ?>
        <!-- end -->
        <!-- Next page link -->
        <?php if (isset($this->next)): ?>
            <li><a href="<?php echo $this->url(array('page' => $this->next)); ?>">Next</a></li>
        <?php else: ?>
            <li><a href="#">Next</a></li>
        <?php endif; ?>
        <?php endif; ?>
    </ul>
</div>




